<template>
  <div>
    <!-- data对应数据 -->
    <!-- row-key 选择的依据 通过id选择 -->
    <!-- tree-props 属性数据的属性 -->
    <!-- default-expand-all 默认展开所有子集 -->
    <el-table
      :data="tableData"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      border
      default-expand-all
    >
      <!-- sortable 排序 -->
      <el-table-column prop="title" label="活动名称" width="180"> </el-table-column>
      <el-table-column prop="begintime" label="开始时间" width="180">
        <template slot-scope="scope">
          <div>{{Number(scope.row.begintime)|fomatetime('yyyy-mm-dd h:m:s')}}</div>
        </template>
      </el-table-column>
      <el-table-column prop="endtime" label="结束时间" width="180">
        <template slot-scope="scope">
          <div>{{Number(scope.row.endtime)|fomatetime('yyyy-mm-dd h:m:s')}}</div>
        </template>
      </el-table-column>
      <el-table-column prop="status" label="状态">
        <template slot-scope="scope">
          <div>
            <el-tag type="success" v-if="scope.row.status == 1">已启用</el-tag>
            <el-tag type="danger" v-if="scope.row.status == 2">禁用</el-tag>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <div>
            <el-button
              type="primary"
              icon="el-icon-edit"
              circle
              @click="edit(scope.row)"
              size="mini"
            ></el-button>
            <el-button
              type="danger"
              icon="el-icon-delete"
              circle
              size="mini"
              @click="del(scope.row.id)"
            ></el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getSeckList,seckillDel } from "@/api.js";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  created() {
    this.getSeckL()
  },
  methods: {
    //获取列表
    async getSeckL() {
      let res = await getSeckList();
      this.tableData = res.list;
    },
    edit(info) {
      this.$emit("edit", info);
    },
    del(id) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          let res = await seckillDel(id);
          if (res.code == 200) {
            this.currentPage=1
           this.getSeckL()
          }
          console.log(res);
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>
<style scoped>
</style>